1. Field of the Invention
This invention relates to an image processing method and apparatus for encoding or decoding image data. By way of example, the invention relates to an image processing method and apparatus for application to an image file or image communication apparatus.
2. Description of the Related Art
An international standard for compressing color image data of a natural picture, which contains an enormous amount of information, has been proposed in recent years by the JPEG (Joint Photographic Experts Group). The method according to this standard shall be referred to as the JPEG coding method below. Though the JPEG coding method is composed of a plurality of systems, the most fundamental is a baseline system.
FIG. 27 is a diagram illustrating the data compression procedure of a baseline system.
First, input image data read by an original reading device such as a scanner is partitioned into blocks each comprising 8.times.8 pixels, after which compression processing is executed in block units. According to the JPEG coding method, the image data that has been read in by the original reading device is not regulated with respect to the color space to be encoded. Often, however, color-space transformation processing is executed as processing which precedes encoding. As for the color space to undergo transformation, there are many color spaces in which it is possible to execute encoding processing highly efficiently. An example of one such color space is that comprising luminance signals and color signals (YC.sub.b C.sub.r, YIQ, Lab, etc.).
In a baseline system, the image data (image data of the original color space or that which results from transformation of the color space) in each block resulting from partitioning is subjected to a discrete cosine transform (hereinafter referred to as "DCT"), which is one type of orthogonal transform (1301). After the original input image data has been transformed to data of space frequency components by DCT, the coefficient at the upper left corner of the 8.times.8 block is referred to as a direct current (DC) component and is a value corresponding to the mean value of the image data of the block before transformation. The other 63 coefficients are referred to as alternating current (AC) components. These are values indicating how many space frequency components corresponding to these positions are contained in the image data of a block before transformation.
DCT coefficients after transformation are divided by values obtained by multiplying 8.times.8 threshold values by scale factors for deciding which values, which are a certain multiple of the threshold values, to use. Quantization is thus carried out (1302). The DCT coefficients after quantization are subjected to encoding processing, which is different for the DC and AC components. Specifically, for the DC components, the difference between a DC component of a processed block and the DC component of the preceding block is subjected to Huffman coding utilizing the strength of correlation between mutually adjacent blocks (1303, 1304). AC components are rearranged in a one-dimensional array by zigzag scanning from a low frequency region to a high frequency region of space frequencies within the block (1305). Further, two-dimensional Huffman coding is performed in sets of coefficients other than zero (these are valid coefficients) and number (run length) of consecutive zeros (non-valid coefficients) (1306.about.1309).
FIG. 16 is a diagram showing an example of an arrangement wherein consideration is given to a case where the above-described encoding method is applied to a color-image communication apparatus.
In FIG. 16, numeral 101 denotes an image reader for scanning the image of an original and outputting multivalued RGB digital color signals. Numeral 103 denotes an image memory for storing image data read by the image reader 101 or image data obtained by decoding encoded data received via a line. Numeral 102 denotes an image printer for printing, in color, an image represented by multivalued digital color signals that have entered from the image memory 103. Numeral 110 denotes a digital signal processor (hereinafter referred to as a "DSP") for encoding image data read out of the image memory 103 or decoding encoded data received via the line. Numeral 107 designates a code memory for storing code data encoded by the DSP 110 or code data received from the line. Numeral 108 denotes a circuit control unit for controlling transmission of code data to the line or reception of code data from the line. Numeral 109 denotes a CPU for monitoring and controlling each of these components via a CPU bus B109. An interrupt-signal line I111 extends from the CPU 109 to the DSP 110, and an interrupt-signal line I112 extends from the DSP 110 to the CPU 109.
The operation for encoding the image data will be described first. FIG. 17 is a flowchart illustrating the encoding processing procedure of the DSP 110. The flowchart illustrates the encoding of one block of image data.
The image of an original is scanned by the image reader 101 and the image data outputted by the image reader 101 is stored temporarily in the image memory 103. It should be noted that image memory 103 is a three-port memory capable of input/output with respect to the image reader 101 or image printer 102, the memory being accessible asynchronously from the CPU 109 and DSP 110.
The DSP 110 adds on a blank space as needed in order to achieve conformity with a prescribed size at step S1. In an image area other than the blank area, the DSP 110 reads one block of image data out of the image memory 103. At step S2 the DSP 110 transforms the color space of the image data to a color space on a circuit line, such as YCbCr color space.
Next, the DSP 110 subjects the image data, which has undergone the color-space transformation, to sub-sampling processing at step S3, to DCT processing at step S4, to quantization at step S5 and to zigzag scanning at step S6, after which it applies Huffman coding at step S7, stores the obtained code data in the code memory 107 and then ends the encoding of the one block of image data.
It should be noted that the code memory 107 also is a three-port memory capable of being accessed asynchronously from the DSP 110, circuit control unit 108 and CPU 109. The circuit control unit 108 reads code data out of the code memory 107 and sends it to the line.
The operation for decoding the received code data will be described next. FIG. 18 is a flowchart illustrating the decoding processing procedure of the DSP 110. The flowchart illustrates the decoding of one block of image data.
The code data received from the line by the circuit control unit 108 is stored in the code memory 107.
The DSP 110 reads the code data out of the code memory 107, performs Huffman coding at step S11 and restores the order of the data that was rearranged by zigzag scanning at the time of encoding.
Next, the DSP 110 subjects the data, which has been restored to the original order, to inverse quantization at step S13 and to inverse-DCT (referred to as "IDCT" hereinafter) at step S14, during Which time the results of these operations are stored in an internal RAM.
The DSP 110 then reads out the operational results stored in the internal RAM, restores the sub-sampling, which prevailed at the time of encoding, at step S15, transforms the color space of the image data from the color space (e.g., the YCbCr color space) on the line to a color space (e.g., CMYK color space) capable of being printed out at step S16, and removes the blank space, which was added on at the time of encoding, at step S17, stores the results in the image memory 103 and ends the decoding of one block of image data.
It should be noted that the image data that has been stored in the image memory 103 is sent to the image printer 102, where the received image is printed.
The arrangement described involves a number of problems, which will now be set forth.
A drawback with the example of the arrangement described above is that processing requires an extended period of time owing to the fact that image processing is executed by a single DSP. More specifically, time needed for processing increases with an increase in the amount of calculation for processing by the DSP software. When there is a large amount of data, as in the case of a color image, the acquisition of processed results is delayed.
The processing for adding on the blank space in the above-described arrangement is such that the blank space, which is necessary to achieve conformity with the size of the reproduced image on the receiving side, is added on to the data on the transmitting side. Accordingly, in a case where the baseline system of the JPEG coding system is applied, the processing for transforming the color space and the processing such as DCT is not applied solely to the image data read in by the image reader such as a scanner; processing similar to that applied to the image data must also be applied to the blank-space data added on to the image on the transmitting side.
Accordingly, in a color-image communication apparatus to which the JPEG coding method is applied, processing for transforming the color space, DCT processing and quantizing processing must be applied to the blank-space data indicative of the blank areas and to the color image data read in by the scanner or the like. When an attempt is made to realize this by the above-mentioned DSP, encoding takes a long period of time since the same operations must be performed regardless of the fact that identical code data is obtained for all of the blank-space data within a block.
Further, the decoding processing procedure is the reverse of the above-mentioned encoding processing. FIG. 35 illustrates the conventional decoding procedure of a baseline system. Here code data sent (transmitted) to another apparatus via a communication transmission line is decoded by Huffman decoding processing, as shown at 2501 in FIG. 35. Data in a one-dimensional array that has been subjected to the decoding processing is rearranged into data of a two-dimensional array at 2502.
With regard to DC components, processing is executed to sum the DC components of a block undergoing processing and the DC components of the preceding block, as indicated at 2503, and the results are adopted as the DC components of the block being processed. As for the AC components, the data after rearrangement is accepted as being valid as is at 2504 since subtraction processing is not carried out at the time of encoding processing. This data is subjected to subsequent processing.
More specifically, both the DC and AC components undergo inverse quantizing processing at 2505 and then a two-dimensional inverse discrete cosine transform at 2506 to complete the decoding processing of one block. In a case where a color-space transformation is necessary, the decoding processing of one block is terminated after the color space transformation.
The encoding/decoding processor of the color-image communication apparatus is necessary for performing blank-space processing in addition to encoding or decoding processing. In blank-space processing, a blank space or margin required on the receiving side is added on to an image on the transmitting side. In many cases the blank-space data added on as a blank is "white". Accordingly, in a case where a baseline system according to the JPEG coding method is applied to a color-image communication apparatus, the processing for transforming the color space and the processing such as DCT is not applied solely to the image data read in by the image reader such as a scanner; processing similar to that applied to the image data must also be applied to the blank-space data (white data) added on to the image on the transmitting side.
Further, in the decoding processing also, the above-mentioned series of decoding processing operations, namely Huffman decoding processing, inverse quantizing processing, IDCT processing and color-space transformation processing, must be executed regardless of the code data to be decoded.
Accordingly, the conventional color-image communication apparatus to which the JPEG coding method is applied subjects blank-area block data (white data) of a blank area and white block image data read in by a scanner, etc., or block image data other than that of a white block, to color-space transformation processing, DCT processing, quantizing processing and Huffman coding processing. At the time of decoding processing, the apparatus subjects all of the code data to Huffman decoding processing, inverse quantizing processing, IDCT processing and color-space transformation processing.
Thus, in the encoding processor of the conventional color-image communication apparatus, even white-block image data or blank-space block data (white data) of a blank area read in by an original reader such as a scanner is subjected to processing similar to that applied to block image data other than that of white blocks, namely color-space transformation processing, DCT processing, quantizing processing and Huffman coding processing, block by block. As a result, the time needed for encoding processing of all image data inclusive of blank-space data is prolonged.